//
//  MainViewController.m
//  UI_test
//
//  Created by dllo on 15/7/23.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "MainViewController.h"
#import "ButtonView.h"
@interface MainViewController ()

@end

@implementation MainViewController

- (void)dealloc
{
    [_button release];
    [_prompt release];
    [super dealloc];
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSLog(@"zhaolu");
    [self createView];
    
}

- (void)createView
{
    
    
    
    self.prompt = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, self.view.frame.size.width - 100, 40)];
    self.prompt.text = @"性别";
    [self.view addSubview:_prompt];
    [_prompt release];
    
    
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    _button.frame = CGRectMake(150, 200, 50, 50);
    [_button setTitle:@"选择" forState:UIControlStateNormal];
    [self.view addSubview:_button];
    [self.button addTarget:self action:@selector(dianji:) forControlEvents:UIControlEventTouchUpInside];

    
    
    
    
    
}

- (void)dianji:(UIButton *)button
{
    self.mView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 150, self.view.frame.size.width, 150)];
    _mView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_mView];
    [_mView release];
    
    
    NSArray *arr = @[@"男",@"女",@"取消"];
    for (int i = 0; i < 3; i++) {
        ButtonView *bView = [[ButtonView alloc] initWithFrame:CGRectMake(0,  50 * i , _mView.frame.size.width, 50) title:[arr objectAtIndex:i]];
        bView.target = self;
        bView.action = @selector(button:);
        [_mView addSubview:bView];
        [bView release];
    }

}


- (void)button:(id)sender
{
    ButtonView *button = (ButtonView *)sender;
    if ([button.label.text isEqualToString:@"男"] || [button.label.text isEqualToString:@"女"]) {
        self.prompt.text = button.label.text;
        [_mView removeFromSuperview];
    }
    else
    {
        [_mView removeFromSuperview];
        
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
